package com.ruoyi.web.controller.durian;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.durian.service.LlDriverService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 司机控制器
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/driver")
public class DriverController extends BaseController {

    @Resource
    private LlDriverService llDriverService;

    /**
     * 司机附近订单列表
     *
     * @param mapX 横坐标
     * @param mapY 纵坐标
     * @return
     */
    @GetMapping("/near/orderList")
    public TableDataInfo orderList(String mapX, String mapY) {
        startPage();
        return getDataTable(llDriverService.orderList(mapX, mapY));
    }

    /**
     * 司机抢单
     *
     * @param orderId 订单id
     * @param userId  乘客id
     * @return
     */
    @PostMapping("/rob/order")
    public AjaxResult robOrder(Integer orderId, Integer userId) {
        return llDriverService.robOrder(orderId, userId);
    }

    /**
     * 取消订单
     *
     * @param orderId
     * @return
     */
    @PostMapping("/close/order")
    public AjaxResult closeOrder(Integer orderId, Integer userId) {
        return llDriverService.closeOrder(orderId, userId);
    }

    /**
     * 司机到达乘客上车位置
     *
     * @param orderId
     * @return
     */
    @PostMapping("/waitlng/after/order")
    public AjaxResult waitlngAfterOrder(Integer orderId) {
        return llDriverService.waitlngAfterOrder(orderId);
    }

    /**
     * 确认乘客上车
     *
     * @param orderId
     * @param phoneEnd
     * @return
     */
    @PostMapping("/confirm/order")
    public AjaxResult confirmOrder(Integer orderId, String phoneEnd) {
        return llDriverService.confirmOrder(orderId, phoneEnd);
    }

    /**
     * 乘客到达目的地
     *
     * @param orderId
     * @return
     */
    @PostMapping("/oevr/order")
    public AjaxResult oevrOrder(Integer orderId) {
        return llDriverService.oevrOrder(orderId);
    }

    /**
     * 聊天界面信息展示
     * @param orderId
     * @return
     */
    @GetMapping("/findCallWith")
    public TableDataInfo findCallWith(Integer orderId,Integer pageNumber,Integer pageSize) {
        return getDataTable(llDriverService.findCallWith(orderId,pageNumber,pageSize));
    }


}
